#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <iostream>
#include <vector>
#include <mpi.h>
#include "tags.h"

class Master{
	private:
		MPI_Request request;
		MPI_Status status;
	
	public:
		Master();
		
		void SetParameters(char* buffer, int bufferSize);
		
		void SendSetBufferSize(int slaveId, int bufferSize);
		void SendResetBufferSize(int slaveId);
		void SendCloseAllThreads(int slaveId);
		void SendSync(int slaveId);
		void SendTerminateSlave(int slaveId);
		void SendJob(int slaveId, char* buffer, int bufferSize); 
		
		int SlaveHasAnyMessage(int slaveId);
		void Receive(int fromSlaveId, char* buffer, int bufferSize);
		
	protected:
		char* buffer;
		int bufferSize;
		
};
